import { postDownload } from '@/utils/request';
import { message } from 'antd';
interface exportLeaderType {
  dateTimeRange: string[] | undefined;
}
export const leaderExportService = async (
  data: exportLeaderType,
  fileName: string | undefined,
) => {
  try {
    const blob = await postDownload('/supersition/exportFile/photoList', data);
    // 创建下载链接
    const url = window.URL.createObjectURL(blob);
    const a = document.createElement('a');
    a.href = url;
    a.download = `supervision_${fileName}.zip`; // 文件名由用户提供
    document.body.appendChild(a);
    a.click();
    document.body.removeChild(a);
    window.URL.revokeObjectURL(url);

    message.success('传输完成，文件下载已开始');
  } catch (error) {
    message.error('文件下载失败');
    console.error('导出失败:', error);
  }
};
